package com.yun.blog.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yun.blog.bean.Blog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;

/**
 * title        : BlogMapper
 * projectName  : dantouBlog-back
 * description  : blogMapper
 * author       : simple
 * date         : 2022/11/23下午9:13
 */

@Mapper
public interface BlogMapper extends BaseMapper<Blog> {
    Blog getByBlogId(@Param("blogId") Integer blogId);

    Integer countByBlogCategoryId(@Param("blogCategoryId") Integer blogCategoryId);

    <P extends IPage<Blog>> P customPage(P page, @Param("searchText") String searchText, @Param("orderBy") String orderBy);

    <P extends IPage<Blog>> P timelinePage(P page);

    List<Blog> listAllByBlogCategoryId(@Param("blogCategoryId") Integer blogCategoryId);

    List<Blog> listAllByTagId(@Param("tagId") Integer tagId);

    List<Blog> getNewBlogByCount(Integer count);

    List<Blog> getByIsTop(@Param("isTop") Boolean isTop);

    int addBlogViews(@Param("blogId") Integer blogId);

    <P extends IPage<Blog>> P getByCondition(
            P page,
            @Param("searchText") String searchText,
            @Param("categoryId") Integer categoryId,
            @Param("isTop") Boolean isTop,
            @Param("tagIdList") Collection<Integer> tagIdList,
            @Param("beginCreateTime") String beginCreateTime,
            @Param("endCreateTime") String endCreateTime,
            @Param("orderBy") String orderBy
    );

    Integer getViewCount();

    Integer getCountByCategoryId(@Param("categoryId") Integer categoryId);

    List<Blog> getViewRank(int count);

    Blog getPrevious(@Param("blogId") Integer blogId);

    Blog getNext(@Param("blogId") Integer blogId);
}
